package StudyCode.summary.myfile;

import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.attribute.DosFileAttributeView;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class FileMetadata {
	public static void main(String[] args) {
		Path path = FileSystems.getDefault().getPath("E:\\迅雷下载", "test1.txt");
		try {
			System.out.println("File Size:" + Files.size(path));
			System.out.println("Is Directory:" + Files.isDirectory(path));
			System.out.println("Is Regular File:" + Files.isRegularFile(path));
			System.out.println("Is Symbolic Link:" + Files.isSymbolicLink(path));
			System.out.println("Is Hidden:" + Files.isHidden(path));
			System.out.println("Last Modified Time:" + Files.getLastModifiedTime(path));
			System.out.println("Owner:" + Files.getOwner(path));

			DosFileAttributeView view = Files.getFileAttributeView(path, DosFileAttributeView.class);
			System.out.println("\nDOS File Attributes\n------------------------------------\n");
			System.out.println("Archive  :" + view.readAttributes().isArchive());
			System.out.println("Hidden   :" + view.readAttributes().isHidden());
			System.out.println("Read-only:" + view.readAttributes().isReadOnly());
			System.out.println("System   :" + view.readAttributes().isSystem());
			view.setHidden(false);

		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
